<!DOCTYPE html>
<html lang="en-us">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title> 作业9 </title>
  
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="robots" content="all,follow">
  <meta name="googlebot" content="index,follow,snippet,archive">
  <meta property="og:title" content="作业9" />
<meta property="og:description" content="作业9 1. Bubble Sort the list: 33, 56, 17, 8, 95, 22。Make sure the final result is from small to large.Write out the list after the 2nd pass. 1st : 8, 33, 56, 17, 22, 95 2nd : 8, 17, 33, 56, 22, 95
2. Give a sorted array as list={60,65,75,80,90,95}. Design an algorithm to insert the value of x into the sorted array. Then test the algorithm with value 50,67,99." />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://beikenken.gitee.io/post/%E4%BD%9C%E4%B8%9A9/" />
<meta property="article:published_time" content="2020-11-04T12:47:10+08:00" />
<meta property="article:modified_time" content="2020-11-04T12:47:10+08:00" />

  <meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="作业9"/>
<meta name="twitter:description" content="作业9 1. Bubble Sort the list: 33, 56, 17, 8, 95, 22。Make sure the final result is from small to large.Write out the list after the 2nd pass. 1st : 8, 33, 56, 17, 22, 95 2nd : 8, 17, 33, 56, 22, 95
2. Give a sorted array as list={60,65,75,80,90,95}. Design an algorithm to insert the value of x into the sorted array. Then test the algorithm with value 50,67,99."/>

  
  
  
  <link rel="stylesheet" href="https://beikenken.gitee.io/css/style-white.css">
  
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  

  
<link rel="icon" type="image/png" href="https://beikenken.gitee.io/images/favicon.ico" />

  
</head>
<body class="max-width mx-auto px3 ltr">
  <div class="content index py4">

    <header id="header">
  <a href="https://beikenken.gitee.io">
  
    <div id="logo" style="background-image: url(https://beikenken.gitee.io/images/logo.png)"></div>
  
  <div id="title">
    <h1>【18342131】的软导作业索引页   全部博客:beikenken.gitee.io/post</h1>
  </div>
  </a>
  <div id="nav">
    <ul>
      <li class="icon">
        <a href="#"><i class="fas fa-bars fa-2x"></i></a>
      </li>
      
    </ul>
  </div>
</header>
  

    
<article class="post" itemscope itemtype="http://schema.org/BlogPosting">

  <div class="content" itemprop="articleBody">
  
    <h1 id="作业9">作业9</h1>
<h2 id="1-bubble-sort-the-list-33-56-17-8-95-22make-sure-the-final-result-is-from-small-to-largewrite-out-the-list-after-the-2nd-pass">1. Bubble Sort the list: 33, 56, 17, 8, 95, 22。Make sure the final result is from small to large.Write out the list after the 2nd pass.</h2>
<p>1st : 8, 33, 56, 17, 22, 95 <br>
2nd : 8, 17, 33, 56, 22, 95</p>
<h2 id="2-give-a-sorted-array-as-list606575809095-design-an-algorithm-to-insert-the-value-of-x-into-the-sorted-array-then-test-the-algorithm-with-value-506799思考为什么选择插入点在list头上中间尾巴上的三个数作为算法测试的数据你能解释吗">2. Give a sorted array as list={60,65,75,80,90,95}. Design an algorithm to insert the value of x into the sorted array. Then test the algorithm with value 50,67,99.思考：为什么选择插入点在list头上、中间、尾巴上的三个数作为算法测试的数据，你能解释吗？</h2>
<pre><code>int i;
if(x &lt; a[0]){
    for(int j = 4; j &gt;= 0; j++){
        a[j + 1] = a[j];
    }
    a[0] = x;
}
else if(a[4] &lt;= x){
    a[5] = x;
}
else{
    for(i = 0; i &lt; 5; i++){
        if(a[i] &lt;= x &amp;&amp; a[i + 1] &gt;  x){
            break;
        }
    }
    for(int j = 4; j &gt;= i + 1； j++){
        a[j + 1] = a[j];
    }
    a[i + 1] = x;
}
</code></pre>
<p>选择插入点在list头上、中间、尾巴上的三个数作为算法测试的数据,是由于这三个数据分别代表了最坏，平均和最好情况。</p>
<h2 id="3-what-is-the-state-of-the-stack-after-the-following-sequence-of-push-and-pop-operations-push-anne-push-get-push-your--pop-push-my-push-gun">3. What is the state of the stack after the following sequence of Push and Pop operations? Push “anne”; Push “get”; Push “your” ; Pop; Push “my” Push “gun”</h2>
<p>栈自顶向下存储的内容为： gun，my，get， anne</p>
<h2 id="思考题-用面向对象的思想描述洗衣机洗衣的程序">思考题 用面向对象的思想描述洗衣机洗衣的程序</h2>
<pre><code>1) 打开洗衣机 
2) 放衣服 
3) 加洗衣粉 
4) 按下开始按钮 
5) 晾晒
</code></pre>

  
  </div>
</article>


    <footer id="footer">
  <div class="footer-left">
    Copyright  &copy; 2021  【18342131】的软导作业索引页   全部博客:beikenken.gitee.io/post 
  </div>
  <div class="footer-right">
    <nav>
      <ul>
        
      </ul>
    </nav>
  </div>
</footer>


  </div>
  
</body>

<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">
<script src="/lib/jquery/jquery.min.js"></script>
<script src="/js/main.js"></script>
</html>
